<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="res/jquery.min.js"></script>
<style type="text/css">
.my_table tr:nth-child(even) {  
        background: #d8ebfa;  
    }  
.my_table tr:nth-child(odd) {  
        background: White;  
    }  
</style>
</head>
<body onload="query()">
	<form action="ShowALLAction" method="post" >
		<table align="center" class="my_table">
		<thead>
			<tr>
				<td colspan="3" align="center">登录信息</td>
			</tr>
			<tr align="center">
				<td>用户ID</td>		
				<td>用户名</td>
				<td>用户密码</td>
			</tr>
			</thead>
			<tbody id="t_body">
			<!--  
			<s:iterator value="Listuser" var="ulist">
				<tr align="center">
					<td>${ulist.uid }</td>
					<td>${ulist.uname }</td>
					<td>${ulist.password}</td>
					<td><a href="deleteUserById?uid=${ulist.uid}">删除</a></td>
				    <td><a href="getUserById?uid=${ulist.uid}">编辑</a></td>
				</tr>
			</s:iterator>
			-->	
			</tbody>
			<tr> <td colspan="5"><a href="adduser.jsp">添加用户</a><td></tr>
		</table>
	</form>
</body>
<script type="text/javascript">
/* 点击按钮触发 */  
function query() {  
    //执行ajax  
    ajaxFun();  
}  
/* ajax代码部分，从jquery帮助文档可直接拷贝 */  
function ajaxFun() {  
    //ajax执行体  
    $.ajax({  
        //提交方式  
        type : "POST",  
        //访问servleturl  
        url : "api/show",  
        //服务器成功返回结果后，会把结果保存到data中  
        success : function(data) {  
            //先把表体部分清空  
            $("#t_body").empty();  
            //eval获取返回的JSON对象集合  
            var d = data.code1;  
            //把数据显示到页面的方法  
            showData(d);  
        }  
    });  
}  
/* 显示数据 */  
function showData(d) {  
    //循环遍历一边d  
    for ( var i = 0; i < d.length; i++) {  
        var html = "<tr><td>" + d[i].uid +"</td><td>" + d[i].uname + "</td><td>" + d[i].password  
                + "</td><td><a href='deleteUserById?uid="+d[i].uid+"'>删除</a></td><td><a href='getUserById?uid="+d[i].uid+"'>修改</a></td></tr>";  
        //通过表体id把显示文本显示到网页中  
        $("#t_body").append(html);  
    }  
}  
</script>
</html>